<?php
class Form_Site_Contact extends Zend_Form 
{
    public function init()
    {
        $this->setMethod('post');
        
        $name = $this->createElement('text', 'name');
        $name->setLabel('Enter your name: ');
        $name->setRequired(TRUE);
        $name->setAttrib('size',50);
        $name->setAttrib('style',"width: 400px");
        $this->addElement($name);
        
        $email = $this->createElement('text', 'email');
        $email->setLabel('E-mail address: ');
        $email->setRequired(TRUE);    
        $email->setAttrib('size',40);
        $email->setAttrib('style',"width: 400px");
        $email->addValidator('EmailAddress');
        $email->addFilters(array(new Zend_Filter_StringTrim() , new Zend_Filter_StringToLower()));
		$email->addErrorMessage('emailAddressInvalidFormat');
        $this->addElement($email);
        
        $subject = $this->createElement('text', 'subject');
        $subject->setLabel('Message subject: ');
        $subject->setRequired(TRUE);
        $subject->setAttrib('size',60);
        $subject->setAttrib('style',"width: 400px");
        $this->addElement($subject);
        
        $message = $this->createElement('textarea', 'message');
        $message->setLabel('Enter your message: ');
        $message->setRequired(TRUE);
        $message->setAttrib('cols',49);
        $message->setAttrib('rows',12);
        $this->addElement($message);
        
        // configure the captcha service
        $privateKey = '6Lf-LwcAAAAAAMSOrrjbogfM6ytHs0u3oLI3Zuv0';
        $publicKey = '6Lf-LwcAAAAAAO9aLI2lhXdcEe6l5PSAtKOo7k4K';
        $recaptcha = new Zend_Service_ReCaptcha($publicKey, $privateKey);
        
        // create the captcha control
        $captcha = new Zend_Form_Element_Captcha('captcha',
            array('captcha'        => 'ReCaptcha',
    		'captchaOptions' => array('captcha' => 'ReCaptcha', 'service' => $recaptcha)));
        
        // add captcha to the form
        //$this->addElement($captcha);
        
        $this->clearDecorators();
        $this->addDecorator('FormElements')
            ->addDecorator('HtmlTag', array('tag'=>'table', 'class'=>'contact-form'))
            ->addDecorator('Form');
            
        $this->setElementDecorators(array(
                            'ViewHelper',
                            'Description',
                            'Errors',
                            array(array('data' => 'HtmlTag'), array('tag' => 'td')),
                            array('Label'),
                            array(array('label' => 'HtmlTag'), array('tag' => 'td', 'class' => 'first')),
                            array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
                            ));
                            
        $submit = $this->createElement('submit','submit');
        $submit->setLabel("Send");
        $submit->setDecorators(array(
        					'ViewHelper',
                            array('Description',array('align'=>'right')),
            				'Errors',
                            array(array('data' => 'HtmlTag'), array('tag' => 'td')),
                            array(array('label' => 'HtmlTag'), array('tag' => 'td', 'placement' => 'prepend')),
                            array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
                            ));
        $this->addElement($submit);  
    }
}
?>